<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
	<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<link href="${pageContext.request.contextPath}/css/org_manager.css"
	rel="stylesheet" type="text/css" />
<link href="${pageContext.request.contextPath}/css/add_new_org.css"
	rel="stylesheet" type="text/css" />
<jsp:useBean id="testBean"
	class="team02.server.bean.TestBean" scope="page"></jsp:useBean>
<script>
function check_selected() {
	var test = document.getElementsByName("selected_id");
	var sizes = test.length;
	for ( var i = 0; i < sizes; i++)
		if (test[i].checked)
			return true;
	alert("一つのテストを選択してください！");
	return false;
}
function check_delete() {
	if (check_selected()) {
		if (confirm("本当にこのテストを削除したいですか")) {
			return true;
		}
	}
	return false;
}
</script>

<div class="menu1"><%@include file="/jsputils/menu.jsp"%>
	<div class = "greeting_message">
		<%@include file="/jsputils/greeting.jsp"%>
	</div>
</div>
<c:set value="<%=testBean.listAllTestByAlias(userBean.getAlias())%>" var="listTest"></c:set>
<div class="container">
<form action="" method="post" name="form" class="table_content">
	<div class="menu">
		<p class="menu_label">テスト管理者</p>
		<%
	//ユーザが団体管理者または出題者の場合
 if(userBean.getAccessLevel()==3||userBean.getAccessLevel()==2){
 %>
 
<p class="menu_item">
<%if(userBean.getOrg_status()==0) {%>
		
			<button type="submit" formaction="uploadcsv.t02" >テスト作成 </button>
			<button type="submit"  formaction="test_mark.t02" onclick="return check_selected()">採点</button>
			<button type="submit" formaction="test_statistics.t02" onclick="return check_selected()">統計</button>	
			<button type="submit"  formaction="test_delete.t02" onclick="return check_delete()">削除</button>
<%} %> 
			
		</p>
		<%
 } 
		//ユーザが採点者の場合
 else if(userBean.getAccessLevel()==4)
 { %>
		<p class="menu_item">
			<a href="test_mark.t02">テスト採点</a> 
			<a href="#">統計を見る</a>
		</p>
		<%} %>
	</div>
		<table style="width: 100%" class="table_content">
			<tr>
				<th></th>
				<th>タイトル</th>
				<th>サブタイトル</th>
				<th>実施日付</th>
				<th>URL</th>
			</tr>
			<c:forEach var="testItem" items="${listTest}">
				<tr>
					<td><input type="radio" name="selected_id"
						value="${testItem.getId()}"></td>
					<td>${testItem.getTitle()}</td>
					<td>${testItem.getSubtitle()}</td>
					<td>${testItem.getStartTimeString2()}</td>
					<td><a href='test_page.t02?u=${testItem.createdBy}&t=${testItem.createdTime}'>テストのURL</a></td>
				</tr>
			</c:forEach>
		</table>
</form>
</div>